package com.example.test.advice.第七章_泛型和反射.建议106_动态代理可以使代理模式更加灵活.dynamic;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SubjectHandler implements InvocationHandler {

    private Subject subject;

    public SubjectHandler(Subject subject) {
        this.subject = subject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("预处理");
        Object object = method.invoke(subject,args);
        System.out.println("后置处理");
        return object;
    }
}
